package com.psu.connection;

import java.sql.Connection;  
import java.sql.DriverManager;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Create By : Anusorn
 * Date : 15/11/13
 * Edit By : Anusorn
 * Date : 2/12/13
 */

public class ConnectionJDBC {
	
	public static Connection getJDBConnection() {
		System.out.println(">>>>> in ConnectionJDBC <<<<<");
		System.out.println("-------------------------------------");
		 String connUrl = "jdbc:mysql://localhost:3306/";
         String driverName = "com.mysql.jdbc.Driver";
         String databaseName = "sccssdb";
         String usrName = "root";
         String usrPass = "root";
	       Connection connection = null;
	        try {
	            Class.forName(driverName).newInstance();
	            connection = DriverManager.getConnection(connUrl + databaseName, usrName, usrPass);
	            if (connection != null) {
	                System.out.println("Connection is connected ");
	            } else {
	                System.out.println("Connection is not null ");
	            }
	            connection.setAutoCommit(false);
	        } catch (ClassNotFoundException e) {
	           Logger.getLogger(ConnectionJDBC.class.getName()).log(Level.SEVERE, null, e);
	        } catch (Exception e) {
	            Logger.getLogger(ConnectionJDBC.class.getName()).log(Level.SEVERE, null, e);
	        }
	        return connection;
	    }
}